package conf

import (
	"fmt"
	"os"

	"github.com/astaxie/beego/logs"
)

// Logger log实例
var Logger *logs.BeeLogger

func LogInit() {
	logdir := LogBase.LogPath

	if !PathExists(logdir) {
		err := os.MkdirAll(logdir, os.ModeDir)
		if err != nil {
			fmt.Println("log dir create fail")
			os.Exit(1)
		}
	}
	LogFileName := logdir + "/" + LogBase.LogName + LogBase.LogExt

	Logger = logs.NewLogger(100000)
	Logger.SetLogger(logs.AdapterFile, `{"filename":"`+LogFileName+`"}`)
	Logger.SetLogger(logs.AdapterConsole)
	Logger.Async()
	Logger.EnableFuncCallDepth(true)
}
